<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition
	template="#{webGlobal.url_template}/administration/main.xhtml">
	<ui:define name="head">

	</ui:define>

	<ui:define name="content">
		<div class="panel panel-default">
			<h:messages warnStyle="color:orange;" infoStyle="color:green;" errorStyle="color:red;"/>
			
			<div class="panel-heading">
				<div class="row">
					<div class="col-md-4 h1 text-center">
						#{adminEditMatch.match.homeTeam.name}</div>
					<div class="col-md-4 h2 text-center">
						#{adminEditMatch.match.scoreHome} -
						#{adminEditMatch.match.scoreOutside}<br />#{adminEditMatch.match.status}
					</div>
					<div class="col-md-4 h1 text-center">#{adminEditMatch.match.outsideTeam.name}</div>
				</div>
			</div>

			<ui:repeat var="event" value="#{adminEditMatch.match.listEvent}">
				<div class="row">
					<div class="col-md-4 text-center"></div>
					<div class="col-md-4 text-center"></div>
					<div class="col-md-4 text-center"></div>
				</div>
			</ui:repeat>
		</div>


		<h:panelGroup rendered="#{adminEditMatch.match.status == 'preparation'}">
			<div>
				<h:form prependId="false">
					<h:commandButton action="#{adminEditMatch.startMatch()}"
						value="Demarrer match"
						styleClass="btn btn-lg btn-primary btn-block">
					</h:commandButton>
				</h:form>
			</div>
		</h:panelGroup>

		<h:panelGroup rendered="#{adminEditMatch.match.status == 'running'}">
			<div class="panel panel-default">
				<div class="panel-heading">Ajouter un évenement</div>
				<h:form prependId="false">
					<div class="col-xs-4">
						<h:selectOneMenu value="#{adminEditMatch.playerSelected}" converter="playerConverter" styleClass="form-control">
							<f:selectItems value="#{adminEditMatch.listPlayer}"></f:selectItems>
						</h:selectOneMenu>
					</div>
					<div class="col-xs-4">
						<h:selectOneMenu value="#{adminEditMatch.typeSelected}" styleClass="form-control">
							<f:selectItems value="#{adminEditMatch.listEventPlayer}"></f:selectItems>
						</h:selectOneMenu>
					</div>
					<h:commandButton value="Enregistrer"
						action="#{adminEditMatch.addEventToMatch()}" styleClass="btn btn-primary btn-inline btn-success"/>
				</h:form>
			</div>
		</h:panelGroup>

		<div class="panel-heading">
			Liste des évènements
		</div>
	
		<table class="table table-hover">
			<thead>
				<tr>
					<th>Joueur</th>
					<th>Evenement</th>
				</tr>
			</thead>
			<tbody>
				<ui:repeat var="event" value="#{adminEditMatch.listPlayerEvent}">
					<tr>
						<td>
							#{event.player.toString()}
						</td>
						<td>
							<h:panelGroup rendered="#{event.typeEventPlayer == 'goal'}">But pour son camp</h:panelGroup>
							<h:panelGroup rendered="#{event.typeEventPlayer == 'csc'}">But contre son camp</h:panelGroup>
							<h:panelGroup rendered="#{event.typeEventPlayer == 'yellowcard'}">Carton jaune</h:panelGroup>
							<h:panelGroup rendered="#{event.typeEventPlayer == 'redcard'}">Carton rouge</h:panelGroup>
						</td>
					</tr>
				</ui:repeat>
				<tr></tr>
			</tbody>
		</table>
			
		<h:panelGroup rendered="#{adminEditMatch.match.status == 'running'}">
			<div>
				<h:form prependId="false">
					<h:commandButton id="stopMatch" action="#{adminEditMatch.stopMatch()}"
						value="Terminer match"
						styleClass="btn btn-lg btn-primary btn-block">
					</h:commandButton>
					
					<h:message for="stopMatch" errorStyle="color: red;"></h:message>
				</h:form>
			</div>
		</h:panelGroup>
		
		<h:outputLabel id="winner" />
		
		<h:message for="winner" infoStyle="color: green"/>
		
	</ui:define>
</ui:composition>
</html>